package com.feng.service.impl;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.feng.dao.IUserConfigDao;
import com.feng.entity.UserConfig;
import com.feng.service.IUserConfigService;
import com.feng.util.CommonUtils;

@Service
@Transactional
public class UserConfigServiceImpl implements IUserConfigService {

	@Autowired
	private IUserConfigDao userConfigDao;
	@Override
	public UserConfig findByUid(String uid) {
		return userConfigDao.findByUid(uid);
	}

	@Override
	public void insertUserConfig(UserConfig userConfig) {
		userConfig.setId(CommonUtils.getUUID());
		userConfig.setCredate(new Date());
		userConfigDao.insertUserConfig(userConfig);
		int i =20/0;
	}

	@Override
	public Integer updateIsSynchro(UserConfig userConfig) {
		return userConfigDao.updateIsSynchro(userConfig);
	}

	@Override
	public String ckUserSync(HttpServletRequest request) {
		String uid = CommonUtils.getCurrentUserId(request);
		UserConfig userConfig = this.findByUid(uid);
		if(userConfig != null) {
			return userConfig.getSynchro();
		}
		return "0";
	}

}
